package com.victor.controller.app;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.github.pagehelper.PageInfo;
import com.victor.entity.ticketorder.OrderUserInfo;
import com.victor.service.OrderuserService;
import com.victor.utils.ClassFilter;
/**
 * 购票信息
 * @author 
 *
 */
import com.victor.utils.Msg;
@RequestMapping("/orderuser")
@RestController
public class OrderUserController {
	@Autowired
	private OrderuserService service;
	
	/**
	 * 添加购票信息
	 * @param orderUserInfo
	 * @return
	 */
	@RequestMapping("/addinfo")
	public Msg addOrderUser(OrderUserInfo orderUserInfo) {
		String[] str = {"uid","oname","ophone","o_idcard"};
		boolean empty = ClassFilter.somePropertyIsEmpty(orderUserInfo, str);
		if (empty ==true) {
			return Msg.fail("入参失败");
		}
		boolean b = service.insert(orderUserInfo);
		return Msg.judge(b);
	}
	
	/**
	 *删除信息
	 * @param ids
	 * @return
	 */
	@RequestMapping("/delete")
	public Msg delete(int[] ids) {
		if (ids == null || ids.length <=0) {
			return Msg.fail("入参错误");
		}
		boolean delete = service.delete(ids);
		return Msg.judge(delete);
	}
	/**
	 * 修改信息
	 * @param orderUserInfo
	 * @return
	 */
	@RequestMapping("/update")
	public Msg update(OrderUserInfo orderUserInfo) {
		if (orderUserInfo.getId() == null) {
			return Msg.fail("入参失败");
		}
		boolean b = service.update(orderUserInfo);
		return Msg.judge(b);
	}
	/**
	 * 查询列表
	 * @param uid
	 * @param page
	 * @param row
	 * @return
	 */
	@RequestMapping("/findall")
	public Msg findAll(String uid,int page,int row) {
		if (uid == null || uid.isEmpty()) {
			return Msg.fail("入参错误");
		}
		PageInfo<OrderUserInfo> selAllByUid = service.selAllByUid(uid,page,row);
		return Msg.success().add("list", selAllByUid);
	}
	/**
	 * 设为默认
	 * @param id
	 * @param uid
	 * @return
	 */
	@RequestMapping("/moren")
	public Msg setMoren(String id,String uid) {
		if (id == null || id.isEmpty() || uid == null || uid.isEmpty()) {
			return Msg.fail("入参失败");
		}
		boolean b = service.updateMoren(id,uid);
		return Msg.judge(b);
	}

}
